package cn.dengta.webapp.user.entity.activity;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Cmp;

/**
 * @author xy
 * @since 2022-12-14
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("act_christmas_user")
public class ActChristmasUser extends TimeBasedEntity {

	private static final long serialVersionUID = 1L;

	/** 奖品数量 */
	Integer prize;
	/** 碎片1 */
	Integer card1;
	/** 碎片2 */
	Integer card2;
	/** 碎片3 */
	Integer card3;
	/** 碎片4 */
	Integer card4;
	/** 碎片5 */
	Integer card5;
	/** 碎片6 */
	Integer card6;

	public static final String PRIZE = "prize";
	public static final String CARD1 = "card1";
	public static final String CARD2 = "card2";
	public static final String CARD3 = "card3";
	public static final String CARD4 = "card4";
	public static final String CARD5 = "card5";
	public static final String CARD6 = "card6";

	public void switchCard(int numNo) {
		switch (numNo) {
			case 1:
				this.card1 += 1;
				break;
			case 2:
				this.card2 += 1;
				break;
			case 3:
				this.card3 += 1;
				break;
			case 4:
				this.card4 += 1;
				break;
			case 5:
				this.card5 += 1;
				break;
			case 6:
				this.card6 += 1;
				break;
		}
	}

	public void make() {
		this.card1 -= 1;
		this.card2 -= 1;
		this.card3 -= 1;
		this.card4 -= 1;
		this.card5 -= 1;
		this.card6 -= 1;
	}

	/***
	 * 是否可拼图
	 */
	public boolean canMake() {
		return Cmp.gt(this.card1, 0) && Cmp.gt(this.card2, 0) && Cmp.gt(this.card3, 0) && Cmp.gt(this.card4, 0) && Cmp.gt(this.card5, 0) && Cmp.gt(this.card6, 0);
	}

}
